import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';
Vue.prototype.$http = axios;
import { Button } from 'vant';
Vue.use(Button);
import { Cell, CellGroup } from 'vant';
Vue.use(Cell).use(CellGroup);
import { Tabbar, TabbarItem } from 'vant';
Vue.use(Tabbar).use(TabbarItem);
import { Circle } from 'vant';
Vue.use(Circle);
import { List } from 'vant';
Vue.use(List);
import { Row, Col } from 'vant';
Vue.use(Row).use(Col);
import { Tab, Tabs } from 'vant';
Vue.use(Tab).use(Tabs);
import { Icon } from 'vant';
Vue.use(Icon);
import { Swipe, SwipeItem } from 'vant';
Vue.use(Swipe).use(SwipeItem);
import { Lazyload } from 'vant';
Vue.use(Lazyload);
import { NoticeBar } from 'vant';
Vue.use(NoticeBar);
import { GoodsAction, GoodsActionBigBtn, GoodsActionMiniBtn } from 'vant';
Vue.use(GoodsAction).use(GoodsActionBigBtn).use(GoodsActionMiniBtn);
import { NavBar } from 'vant';
Vue.use(NavBar);
import { Field } from 'vant';
Vue.use(Field);
import { SubmitBar } from 'vant';
Vue.use(SubmitBar);
import { Loading } from 'vant';
Vue.use(Loading);
import { Dialog } from 'vant';
Vue.use(Dialog);
import { Tag } from 'vant';
Vue.use(Tag);
import { Popup } from 'vant';
Vue.use(Popup);
import '../static/css/style.css';
import { Actionsheet } from 'vant';
Vue.use(Actionsheet);
import { DatetimePicker } from 'vant';
Vue.use(DatetimePicker);

// 读取Cookie
Vue.prototype.getCookie = function(c_name) {
  if (document.cookie.length > 0) {
    var c_start = document.cookie.indexOf(c_name + '=');
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1;
      var c_end = document.cookie.indexOf(';', c_start);
      if (c_end == -1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start, c_end));
    }
  }
  return '';
};
Vue.prototype.setCookie = function(name, value, day) {
  if (day !== 0) {     // 当设置的时间等于0时，不设置expires属性，cookie在浏览器关闭后删除
    var expires = day * 24 * 60 * 60 * 1000;
    var date = new Date(+new Date() + expires);
    document.cookie = name + '=' + escape(value) + ';expires=' + date.toUTCString();
  } else {
    document.cookie = name + '=' + escape(value);
  }
};

Vue.prototype.httpUrl = 'http://sfjc.hikaru.fun';  // 注册全局

new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
});
